package com.chanyachting.emall.serviceImpl;

import java.util.List;

import com.chanyachting.emall.dao.BrandDAO;
import com.chanyachting.emall.domain.Brand;
import com.chanyachting.emall.domain.Companyproduct;
import com.chanyachting.emall.service.BrandService;

public class BrandServiceImpl implements BrandService {
	
	private BrandDAO bdao;
	
	public BrandServiceImpl(){
		
		this.bdao=new BrandDAO();
	}
	

	public boolean createBrand(Brand brand) {
		
		this.bdao.save(brand);
		
		return true;
	}

	public boolean deleteBrand(Brand brand) {
		
		this.bdao.delete(brand);
		
		return true;
	}

	public List<Brand> getAllBrand() {
		
		return this.bdao.find("from Brand");
	}

	public List<Companyproduct> getCompanyProductListByBrand(Brand brand) {
		
		String args[]={String.valueOf(brand.getId())};
		
		return this.bdao.find("from Companyproduct where brandId=? and status='01'", args);
	}

	public Brand getOneBrand(Brand brand) {
		
		return (Brand) this.bdao.load(Brand.class, brand.getId());
	}

	public boolean updateBrand(Brand brand) {
		
		this.bdao.update(brand);
		
		return true;
			
	}

}
